#ifndef _AMERICO_STATIC_ARRAY_H_
#define _AMERICO_STATIC_ARRAY_H_

#include "DL_Debug.h"

namespace Utilities
{
	template <class Type, int Size>
	class StaticArray
	{
	private:
		Type myContainer[Size];
	public:
		StaticArray();
		StaticArray(const StaticArray &aStaticArray);
		virtual ~StaticArray();

		StaticArray &operator=(const StaticArray &aStaticArray);

		inline const Type &operator[](const int &anIndex) const;
		inline Type &operator[](const int &anIndex);

		unsigned int size() const { return Size; }
		inline void Insert(int anIndex, const Type &anObject);
		inline void DeleteAll();
	};

	template <class Type, int Size>
	StaticArray<Type, Size>::StaticArray()
	{
	}
	template <class Type, int Size>
	StaticArray<Type, Size>::StaticArray(const StaticArray &aStaticArray)
	{
		for(unsigned int index=0; index<Size; index++)
		{
			myContainer[index] = aStaticArray.myContainer[index];
		}
	}
	template <class Type, int Size>
	StaticArray<Type, Size>::~StaticArray()
	{
	}
	template <class Type, int Size>
	StaticArray<Type, Size> &StaticArray<Type, Size>::operator=(const StaticArray &aStaticArray)
	{
		for(unsigned int index=0; index<Size; index++)
		{
			myContainer[index] = aStaticArray.myContainer[index];
		}
		return *this;
	}
	template <class Type, int Size>
	inline const Type &StaticArray<Type, Size>::operator[](const int &anIndex) const
	{
		DL_CHK_ASSERT((anIndex>=0) && (anIndex<Size), "Error: Index Out Of Bounds!");
		return myContainer[anIndex];
	}
	template <class Type, int Size>
	inline Type &StaticArray<Type, Size>::operator[](const int &anIndex)
	{
		DL_CHK_ASSERT((anIndex>=0) && (anIndex<Size), "Error: Index Out Of Bounds!");
		return myContainer[anIndex];
	}
	template <class Type, int Size>
	inline void StaticArray<Type, Size>::Insert(int anIndex, const Type &anObject)
	{
		DL_CHK_ASSERT((anIndex>=0) && (anIndex<Size), "Error: Index Out Of Bounds!");
		memmove(myContainer+anIndex+1, myContainer+anIndex, (Size-anIndex-1)*sizeof(Type));
		myContainer[anIndex] = anObject;
	}
	template <class Type, int Size>
	inline void StaticArray<Type, Size>::DeleteAll()
	{
		for(unsigned int index=0; index<Size; index++)
		{
			delete myContainer[index];
		}
	}
};
namespace Utils=Utilities;

#endif
